import request from "@/utils/request";

/**
 * 用户登录
 */
export function login(data: { username: string; password: string }) {
	return request.post("/api/auth/login", data);
}

/**
 * 用户注册
 */
export function register(data: {
	username: string;
	password: string;
	confirmPassword: string;
}) {
	return request.post("/api/auth/register", data);
}

/**
 * 获取用户信息
 */
export function getUserInfo() {
	return request.get("/api/auth/profile");
}

/**
 * 更新用户信息
 */
export function updateUserInfo(data: any) {
	return request.put("/api/users/profile", data);
}

/**
 * 获取用户积分明细
 */
export function getUserPoints(params?: {
	page: number;
	limit: number;
	userId?: number;
}) {
	return request.get("/api/points/", { params });
}

/**
 * 修改密码
 */
export function changePassword(data: {
	oldPassword: string;
	newPassword: string;
	confirmPassword: string;
}) {
	return request.put("/api/auth/password", data);
}
